//package com.qax.task.cron.processor;
//
//import com.qax.task.cron.CronTask;
//import com.qax.task.cron.CronTrigger;
//import com.qax.task.cron.ScheduledTask;
//import com.qax.task.cron.TaskRejectedException;
//import com.qax.task.cron.support.ScheduledTaskRegistrar;
//
//import java.net.Authenticator;
//import java.net.InetSocketAddress;
//import java.net.ProxySelector;
//import java.net.URI;
//import java.net.http.HttpClient;
//import java.net.http.HttpRequest;
//import java.net.http.HttpResponse;
//import java.util.Optional;
//import java.util.concurrent.Flow;
//
///**
// * <BR>计划cron处理器<BR/>
// *
// * @author leiliang
// */
//public class ScheduledCronProcessor implements Processor<ScheduledTask> {
//
//    public static  final ScheduledTaskRegistrar REGISTRAR = new ScheduledTaskRegistrar();
//
//    private Optional<Runnable> runnable;
//
//    private Optional<String> cron;
//
//    /**
//     * @param runnable
//     * @param cron
//     */
//    public ScheduledCronProcessor(Runnable runnable, String cron) {
//        this.runnable = Optional.ofNullable(runnable);
//        this.cron = Optional.ofNullable(cron);
////        HttpClient client = HttpClient.newHttpClient();
//        HttpRequest request = HttpRequest.newBuilder()
////                .uri(URI.create("http://openjdk.java.net/"))
////                .build();
////        client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
////                .thenApply(HttpResponse::body)
////                .thenAccept(System.out::println)
////                .join();
//
//
//        HttpClient client = HttpClient.newBuilder()
//                .version(HttpClient.Version.HTTP_2)
//                .followRedirects(HttpClient.Redirect.NORMAL)
//                .proxy(ProxySelector.of(new InetSocketAddress("www-proxy.com", 8080)))
//                .authenticator(Authenticator.getDefault())
//                .build();
//
//        client.sendAsync(request,HttpResponse.BodyHandlers.fromSubscriber());
//    }
//
//
//
//    @Override
//    public void doBeforeProcess() {
//        //valid before
//        System.out.println("Do before of valid ...");
//    }
//
//    @Override
//    public ScheduledTask exec() {
//        try {
//           return this.REGISTRAR.scheduleCronTask(
//                    new CronTask(runnable.get(),
//                            new CronTrigger(this.cron.get())));
//        } catch (TaskRejectedException e) {
//            e.printStackTrace();
//
//        }
//        return null;
//    }
//}
